<template>
	<view class="container">
		<navbar :config="config"></navbar>
		
		<view v-if="walletList.length>0">
		<view class="list" v-for="(item,index) in walletList" :key='item.id'>
			<view class="item">
				<view class="u-flex-center-sb u-181818">
					<view class="u-font26">{{item.mode}}</view>
					<view class="u-font36 u-bold  u-FF0000" v-if="item.bill_type==1">+{{item.entry_value}}</view>
					<view class="u-font36 u-bold  u-666" v-if="item.bill_type==0">-{{item.entry_value}}</view>
				</view>
				<view class="u-mt10 u-font22">{{item.format_create_time_millis}}</view>
			</view>
		</view>
		</view>
		<!-- 没有数据 -->
		<loadMore v-if="walletList.length>0" :status="status"></loadMore>
			<nodata v-else :config="{top:20,content:'暂无数据~'}"></nodata>
		
	</view>
</template>

<script>
	export default {
			data() {
				return {
					config: {
						back: true, //false是tolbar页面 是则不写
						title: '钱包明细',
						color: '#1A1A1A',
						//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
						backgroundColor: [1, "#FFFFFF"],
						statusBarFontColor: '#1A1A1A'
					},
					walletList:[],
					params:{
						page:1,
						limit:20,
					},
					status:"more",
					totalPage:null,
					currPage:null,
					
				}
			},
			onReachBottom(e){
				if(this.totalPage<=this.currPage){
					this.status="noMore"
				}else{
					this.status = "more"
					this.params.page++
					this.getList()
				}
			},
			onLoad() {
				//获取钱包明细
				this.getList()
			},
			onPullDownRefresh() {
				this.params.page=1
				this.walletList=[]
				this.getList()
			},
			onReachBottom(e){
				if(this.totalPage<=this.currPage){
					this.status="noMore"
				}else{
					this.status="more"
					this.params.page++
					this.getList()
				}
			},
			methods:{
				getList(){
					this.$http.get('/usergains/userbill/page',this.params).then(res => {
						if(res&&res.code==200){
							console.log(res)
							uni.stopPullDownRefresh()
						 this.walletList= this.walletList.concat( res.page.list)
						 this.totalPage = res.page.totalPage
						 this.currPage = res.page.currPage
						 if(this.totalPage<=this.currPage){
							 this.status="noMore";
						 }else{
							 this.status="more"
						 }
						}
					})
				}
			}
		}
</script>

<style lang="scss">
	.list{
		.item{
			padding:20rpx 30rpx 24rpx;
			border-bottom: 1rpx solid  #E6E6E6;
		}
	}
</style>
